<template>
    <div class="app-container">
        <a-card>
            <BasicTable ref="tableRef" :params="params" :columns="columns" :selectbox="false" :query="query">
                <template #form>
                    <a-form-item label="标题" name="title">
                        <a-input v-model:value="params.title" placeholder="请输入标题" />
                    </a-form-item>
                </template>
                <template #table="{ body }">
                    <template v-if="body.column.key === 'type'">
                        <dict-text :value="body.record.type" dict-code="noticeType" />
                    </template>
                    <template v-if="body.column.key === 'priority'">
                        <dict-text v-model:value="body.record.priority" dict-code="priority" />
                    </template>
                    <template v-if="body.column.key === 'status'">
                        <dict-text v-model:value="body.record.status" dict-code="readStatus" />
                    </template>
                    <template v-if="body.column.key === 'createDate'">
                        {{ parseTime(body.record.createDate) }}
                    </template>
                    <template v-if="body.column.key === 'revocationDate'">
                        {{ body.record.revocationDate ? body.record.revocationDate : '--' }}
                    </template>
                    <template v-if="body.column.key === 'action'">
                        <a-button type="link" @click="view(body.record)">
                            <template #icon>
                                <SearchOutlined />
                            </template>
                            查看
                        </a-button>
                    </template>
                </template>
            </BasicTable>
        </a-card>
        <modal ref="modalRef" @close="refresh(tableRef)" />
    </div>
</template>
<script setup name="NoticeUserModule">
import { reactive, ref } from 'vue'
import { SearchOutlined } from '@ant-design/icons-vue'
import { query } from '/@/api/System/NoticeUser'
import { useBasicTable } from '@iframe/tools/mixins/BasicTableMixins'
import { DictText, BasicTable } from '@iframe/tools/components'
import Modal from './Modal.vue'

const { refresh } = useBasicTable()
const tableRef = ref()
const modalRef = ref()
const params = reactive({})
const columns = [
    {
        title: '标题',
        dataIndex: 'title',
        key: 'title'
    },
    {
        title: '消息类型',
        dataIndex: 'type',
        key: 'type',
        width: 150,
        align: 'center'
    },
    {
        title: '阅读状态',
        dataIndex: 'status',
        key: 'status',
        width: 130,
        align: 'center'
    },
    {
        title: '操作',
        key: 'action',
        align: 'center',
        width: 120
    }
]
const view = row => {
    modalRef.value.open(row)
}
</script>
